package com.wanxin.wb.common.service.impl;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.wanxin.wb.common.dao.mysql.IUserDao;

import com.wanxin.wb.common.dao.oracle.master.IUserReadWriteDao;
import com.wanxin.wb.common.dao.oracle.slave.IUserReadOnlyDao;

import com.wanxin.wb.common.model.UserVO;
import com.wanxin.wb.common.service.IUserService;

@Service
public class UserServiceImpl2 implements IUserService {
	private Logger logger = Logger.getLogger(this.getClass());
	

	
	
	@Autowired
	private IUserReadWriteDao iUserMasterDao;
	
	
	@Autowired
	private IUserReadOnlyDao iUserSlaveDao;
	

	
	public UserVO getByAccount(String username, String password) throws Exception {
		if (username == null || "".equals(username)) {
			logger.warn("门店编码为null或空，请检查！");
			throw new Exception("门店编码为空");
		}
		//return userDao.findByAccount(username, password);
		
		return iUserMasterDao.findByAccount(username, password);
	}

	@Override
	public UserVO getByAccount2(String username, String password)
			throws Exception {
		if (username == null || "".equals(username)) {
			logger.warn("门店编码为null或空，请检查！");
			throw new Exception("门店编码为空");
		}
		return iUserSlaveDao.findByAccount(username, password);
	}

}
